<!--
 * @Author: suo.tianbao suo.tianbao@vpclub.cn
 * @Date: 2023-09-01
 * @LastEditors: suo.tianbao suo.tianbao@vpclub.cn
 * @LastEditTime: 2024-03-05
 * @FilePath: /element-admin/src/views/FoodCalDinnerMap.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div id="Member-Point-History-page">
    <!--顶部搜索栏-->
    <div class="col-md-12">
      <el-row :gutter="20">
        <el-col :span="22" :offset="1" class="clearfix">
          <el-form :inline="true" :model="query" class="demo-form-inline">
            <el-form-item label="计算日期">
            <el-date-picker
                v-model="today_value"
                align="right"
                type="date"
                placeholder="计算日期"
                :picker-options="pickerOptions">
            </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button type="info" @click="handleDayExut" size="small">1.全会员餐食执行计算</el-button>
              <el-button type="info" @click="handleMemExut" size="small">2.统计会员餐食总量计算</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>
    <!--中部数据表格栏-->
    <div class="col-md-12">
      <el-row :gutter="20">
        <el-col :span="22" :offset="1" class="clearfix">
          <template>
            <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
              <el-tab-pane label="菜品计算" name="first">
                <el-row :gutter="20">
                  <el-col :span="22" :offset="1" class="clearfix">
                    <el-card class="box-card" style="height: 680px">
                      <FoodCalDinnerTab :drawId="activeName"></FoodCalDinnerTab>
                    </el-card>
                  </el-col>
                </el-row>
              </el-tab-pane>
              <el-tab-pane label="热量缺口计算" name="second">
                <el-row :gutter="20">
                  <el-col :span="22" :offset="1" class="clearfix">
                    <el-card class="box-card" style="height: 680px">
                      <FoodCalHeatGapTabView :drawId="activeName"></FoodCalHeatGapTabView>
                    </el-card>
                  </el-col>
                </el-row>
              </el-tab-pane>
              <el-tab-pane label="食料汇总" name="third">
                <el-row :gutter="20">
                  <el-col :span="22" :offset="1" class="clearfix">
                    <el-card class="box-card" style="height: 680px">
                      <FoodCalDinnerTotTabView :drawId="activeName"></FoodCalDinnerTotTabView>
                    </el-card>
                  </el-col>
                </el-row>
              </el-tab-pane>
            </el-tabs>
          </template>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
import {mapMutations} from "vuex";
import {exutDayDinner, exutDayDinnerTot, exutMemDinner} from "@/api/MemberWeight";
import FoodCalDinnerTab from '@/views/hcm/FoodCalDinnerTabs/FoodCalDinnerTab.vue';
import FoodCalHeatGapTabView from '@/views/hcm/FoodCalDinnerTabs/FoodCalHeatGapTab.vue';
import FoodCalDinnerTotTabView from '@/views/hcm/FoodCalDinnerTabs/FoodCalDinnerTotTab.vue'

export default {
  name: "FoodCalDayMapView",
  components: {FoodCalDinnerTab, FoodCalHeatGapTabView, FoodCalDinnerTotTabView},
  data() {
    return {
      activeName: 'first',
      today_value: new Date(),
      query: {key: '',},
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date());
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }, {
          text: '一周前',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', date);
          }
        }]
      },
    }
  },
  computed: {},
  methods: {
    ...mapMutations(['add_tab']),
    init_obj() {
      return {}
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    handleDinnerExut() {
      this.isLoading = true;
      exutDayDinner().then(res=> {
        if (res.code == 200) {
          this.isLoading = false;
          this.$notify({title: '执行成功', message: '数据操作完成', type: 'success', offset: 100});
        }
      }).catch(err => {
        this.$notify({title: '执行失败', message: '数据操作异常' + err, type: 'error', offset: 100});
      });
    },
    // 计算一周随机菜单
    handleDayExut() {
      this.isLoading = true;
      exutDayDinnerTot().then(res=> {
        if (res.code == 200) {
          this.isLoading = false;
          this.$notify({title: '执行成功', message: '数据操作完成', type: 'success', offset: 100});
        }
      }).catch(err => {
        this.$notify({title: '执行失败', message: '数据操作异常' + err, type: 'error', offset: 100});
      });
    },
    // 计算会员食材
    handleMemExut() {
      this.isLoading = true;
      exutMemDinner().then(res => {
        if (res.code == 200) {
          this.isLoading = false;
          this.$notify({title: '执行成功', message: '数据操作完成', type: 'success', offset: 100});
        }
      }).catch(err => {
        this.$notify({title: '执行失败', message: '数据操作异常' + err, type: 'error', offset: 100});
      });
    },
  },
  created() {

  },
  mounted() {
  },
}
</script>
<style scoped>

.demo-date-picker {
  display: flex;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
}

.demo-date-picker .block {
  padding: 30px 0;
  text-align: center;
  border-right: solid 1px var(--el-border-color);
  flex: 1;
}

.demo-date-picker .block:last-child {
  border-right: none;
}

.demo-date-picker .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}
</style>